// picInit - should always be called as first item to initialize common resources

#include "userLib.h"

// variables externd by other modules needing clock variables

// Clock and timer settings

uint32 			sysclk;			// system clock speed
uint32 			pbclk;			// peripheral bus clock speed
uint16			timer_ticks_per_microsec;  // time base for delays; See userLib.h for prescale
unsigned char	freeclk_timer_reset_value; // free running clock setting made at reset or at interrupt	 

uint32 picInit( uint32 primaryClockSpeed, uint32 periphBusClockSpeed )
{
	// set clock variables
	sysclk = primaryClockSpeed;
	pbclk = periphBusClockSpeed;
	timer_ticks_per_microsec = pbclk/1000000L/4/TIMER_PRESCALE;
	freeclk_timer_reset_value = 256 - ( (78 * timer_ticks_per_microsec) / 5);
}

